#include <iostream>
using namespace std;
//引用
void swap(int &a, int &b);
int main()
{
    int x = 5, y = 6;
    swap(x, y);
    cout << x << " " << y << endl;
    system("pause");
    return 0;
}
void swap(int &a, int &b)
{
    int t;
    t = a;
    a = b;
    b = t;
}

#include <iostream>
using namespace std;
//指针
void swap(int *a, int *b);
int main()
{
    int x = 5, y = 6;
    swap(&x, &y);
    cout << x << " " << y << endl;
    system("pause");
    return 0;
}
void swap(int *a, int *b)
{
    int t;
    t = *a;
    *a = *b;
    *b = t;
}
